
// XortStudioView.h : interface of the CXortStudioView class
//

#pragma once

class CXortStudioCntrItem;
class CProgressDlg;

class CXortStudioView : public CRichEditView
{
protected: // create from serialization only
	CXortStudioView();
	DECLARE_DYNCREATE(CXortStudioView)

// Attributes
public:
	CXortStudioDoc* GetDocument() const;

// Operations
public:
    void ShowDisassembly(  const CString& csDisAsm );
    void LocateSymbol( symbolref pSymbol );
    void ScrollIntoView( DWORD dwLineIdx );
    void MoveDebugCursorToLine( DWORD dwLineIdx );

// Overrides
public:
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
	virtual void OnInitialUpdate(); // called first time after construct
	virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);

// Implementation
public:
	virtual ~CXortStudioView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

private:
    CHARFORMAT2   cfBlue;
    CHARFORMAT2   cfBlack;
    CHARFORMAT2   cfGreen;
    CHARFORMAT2   cfRed;

    CString       m_csAsmRTF;
    DWORD         m_dwIdx;
    DWORD         m_dwDbgCursorIdx;
    DWORD         m_dwNativeThreadID;
    
    CProgressDlg *m_pProgressDlg;

    static UINT __cdecl LoadDisassemblyThreadProc( LPVOID pParam );
    CWinThread *m_pDisassemblerThread;
    void LoadDisassemblyIntoRichEdit();
    
    enum { CLR_BLACK, CLR_RED, CLR_GREEN, CLR_BLUE, };

    void AppendString( LPCSTR lpszText, DWORD dwColor );

    static DWORD __stdcall RichEditOutStreamCBStatic( DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb );
    DWORD RichEditOutStreamCB( LPBYTE pbBuff, LONG cb, LONG *pcb );

    static DWORD __stdcall RichEditInStreamCBStatic( DWORD_PTR dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb );
    DWORD RichEditInStreamCB( LPBYTE pbBuff, LONG cb, LONG *pcb );
    
    void UpdateBreakpointLine( DWORD dwLineIdx, BOOL bHas );

// Generated message map functions
protected:
	afx_msg void OnDestroy();
	afx_msg void OnFilePrintPreview();
	afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
    afx_msg void OnPaint();
    afx_msg LRESULT OnAppendDisasmString( WPARAM wParam, LPARAM lParam );
    afx_msg void OnKeyUp( UINT nChar, UINT nRepCnt, UINT nFlags );

	DECLARE_MESSAGE_MAP()
};

#ifndef _DEBUG  // debug version in XortStudioView.cpp
inline CXortStudioDoc* CXortStudioView::GetDocument() const
   { return reinterpret_cast<CXortStudioDoc*>(m_pDocument); }
#endif

